package com.wanmait.community.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanmait.community.entity.Car;
import com.wanmait.community.mapper.CarMapper;
import com.wanmait.community.service.CarService;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional(rollbackFor = Exception.class)
public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements CarService{
@Resource
private CarMapper carMapper;
    @Override
    public PageInfo<Car> getCar(Car car,int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Car> carList = carMapper.getCarList();
        PageInfo<Car> pageInfo = new PageInfo<>(carList,3);
        return pageInfo;

    }





    @Override
    public void addCar(Car car) {
        carMapper.insert(car);
    }

    @Override
    public void updateCar(Integer id) {
        carMapper.ubdate(id);
    }

    @Override
    public PageInfo<Car> getCarList(Car car, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Car> list =  carMapper.getCarListBy(car);
        PageInfo<Car> pageInfo = new PageInfo<>(list,3);
        return pageInfo;
    }

    @Override
    public Car getCarById(Integer id) {
        Car car =  carMapper.getCarById(id);
        return car;
    }

    @Override
    public void handleupdate(Car car) {
        carMapper.handleupdate(car);
    }

    @Override
    public List<Car> getCar() {
        return carMapper.getCarList();

    }

    @Override
    public List<Car> handlelist() {
        return carMapper.handlelist();

    }
}
